<?php

namespace app\common\traits;

use support\Response;

trait ApiTrait
{
    /**
     * 操作成功
     */
    public function reSuccess($msg = '', $data = []) : Response
    {
        return json(array('code' => 200, 'msg' => $msg, 'data' => $data));
    }

    /**
     * 操作失败
     */
    public function reError($msg = '', $isMsgPrompt = true, $code = 500) : Response
    {
        return json(array('code' => $code, 'msg' => $msg, 'data' => [], 'isPrompt' => $isMsgPrompt));
    }
}
